<template>
	<view style="padding: 20rpx 20rpx 160rpx 20rpx;">
		<view class="list">
			<view class="list_top">
				<view class="list_title">
					<view class="title_name">
						{{teamcontent.name}}-{{teamcontent.user.encoded}}
						<text class="guanzhu" @tap="interest" v-if='user.group_id == 2'>
							{{teamcontent.is_focus?'取消关注':'关注TA'}}
						</text>
					</view>
					<view class="bottom_list flex wrap">
						<text v-if='user.group_id == 3'>需求：</text>
						<view class="bottom_lists" v-for="(team,index) in teamcontent.troops_arr"
							>
							{{team}}
						</view>
						<view class="bottom_lists2" v-for="(team,index) in teamcontent.work_arr">
							{{team}}
						</view>
					</view>
				</view>
			</view>

		</view>

		<view class="pingtai">
			<!-- <image src="../../static/logo.png" mode="widthFix"></image> -->
			<!-- <image src="../../static/icon/icon/home/renzheng.png" mode=""></image> -->
			<text class="zheng" v-for="(list,index) in teamcontent.verify_arr" :key="index">
				{{list}} <text v-if="index!=teamcontent.verify_arr.length -1"> /</text>
			</text>
		</view>
		<view class="jianjie">
			<view class="title" v-if="user.group_id == 2">
				队伍简介
			</view>
			<view class="title" v-if="user.group_id == 3">
				项目简介
			</view>
			<view class="contents">
				{{teamcontent.introduce?teamcontent.introduce:'暂无'}}
			</view>
		</view>
		<view class="jianjie" >
			<!-- <view class="title" v-if="user.group_id == 2">
				队伍信息
			</view> -->
			<view class="title" v-if="user.group_id == 3">
				项目信息
			</view>
			<view class="tdistr" v-if="user.group_id == 3">
				<view class="tdistr_list" v-if="user.group_id == 3">
					<view class="left">
						队伍类型
					</view>
					<view class="right">
						<text v-for="(list,index) in teamcontent.troops_arr">{{list}}</text>
					</view>
				</view>
				<view class="tdistr_list" v-if="user.group_id == 3">
					<view class="left">

						<text >项目类型</text>
						<!-- <text v-else>涉及专业</text> -->
					</view>
					<view class="right">
						<text v-for="(list,index) in teamcontent.work_arr">{{list}}/</text>
					</view>
				</view>
				<view class="tdistr_list" v-if="user.group_id == 3">
					<view class="left">
						<text >工程量</text>
					</view>
					<view class="right">
						{{teamcontent.quantities}}
					</view>
				</view>
				<view class="tdistr_list" v-if="user.group_id == 3">
					<view class="left">
						<text>工期</text>
					</view>
					<view class="right">
						{{teamcontent.time_limit}}
					</view>
				</view>
				<view class="tdistr_list" v-if="user.group_id == 3">
					<view class="left">

						<text>项目所处阶段</text>
					</view>
					<view class="right">

						<text >{{teamcontent.projec_stage}}</text>
					</view>
				</view>
				<view class="tdistr_list" v-if="user.group_id == 3">
					<view class="left">
						<text>预计进场时间</text>
					</view>
					<view class="right">
						<text>{{teamcontent.enter_time}}</text>
					</view>
				</view>
				<!-- <view class="tdistr_list" v-if="user.group_id == 3">
					<view class="left">
				
						<text v-if="user.group_id == 3">工价</text>
					</view>
					<view class="right">
				
						<text v-if="user.group_id == 3">{{teamcontent.price}}</text>
						
					</view>
				</view>
				<view class="tdistr_list" v-if="user.group_id == 3">
					<view class="left">
				
						<text v-if="user.group_id == 3">结算比例(月结)</text>
					</view>
					<view class="right">
				
						<text v-if="user.group_id == 3">{{teamcontent.settlement_prop}}</text>
						
					</view>
				</view> -->
				<view class="tdistr_list" v-if="user.group_id == 3">
					<view class="left">
						<text >项目地点</text>
					</view>
					<view class="right">
						<text>{{teamcontent.province}}</text>
					</view>
				</view>
			</view>
		</view>
		<view class="jianjie" v-if='user.group_id == 3'>
			<view class="title">
				发包信息
			</view>
			<view class="tdistr">
				<view class="tdistr_list">
					<view class="left">
						发包人角色
					</view>
					<view class="right">
						{{teamcontent.employer_role}}
					</view>
				</view>
				<view class="tdistr_list">
					<view class="left">

						<text>发包类型</text>

					</view>
					<view class="right">
						{{teamcontent.contract_type}}
					</view>
				</view>
				<view class="tdistr_list">
					<view class="left">

						<text>建设单位企业性质</text>

					</view>
					<view class="right">
						{{teamcontent.fb_employer_unit}}
					</view>
				</view>
				<view class="tdistr_list">
					<view class="left">

						<text>总包单位企业性质</text>

					</view>
					<view class="right">
						{{teamcontent.fb_total_employer_unit}}
					</view>
				</view>
			</view>
		</view>
		<view class="jianjie" v-if='user.group_id == 3'>
			<view class="title">
				工程报酬
			</view>
			<view class="tdistr">
				<view class="tdistr_list">
					<view class="left">
						合同价格形势
					</view>
					<view class="right">
						{{teamcontent.price_contract}}
					</view>
				</view>
				
				<view class="tdistr_list">
					<view class="left">
						付款节点及付款比例
					</view>
					<view class="right">
						{{teamcontent.payment_prop}}
					</view>
				</view>
				<view class="tdistr_list">
					<view class="left">
						<text>结算方式</text>
					</view>
					<view class="right">
						{{teamcontent.settlement_method}}
					</view>
				</view>
			</view>
		</view>
		<view class="jianjie" v-if='user.group_id == 3'>
			<view class="title">
				项目要求
			</view>
			<view class="tdistr">
				<view class="tdistr_list">
					<view class="left">
						质量要求
					</view>
					<view class="right">
						{{teamcontent.quality_requirement}}
					</view>
				</view>
				<view class="tdistr_list">
					<view class="left">
						<text>业绩要求</text>
					</view>
					<view class="right">
						{{teamcontent.achievement_requirement}}
					</view>
				</view>
				<view class="tdistr_list">
					<view class="left">
						人员要求
					</view>
					<view class="right">
						{{teamcontent.personnel_requirement}}
					</view>
				</view>
				<view class="tdistr_list">
					<view class="left">
						资质要求
					</view>
					<view class="right">
						{{teamcontent.natural_requirement}}
					</view>
				</view>
				<view class="tdistr_list">
					<view class="left">
						履约保证金
					</view>
					<view class="right">
						{{teamcontent.performance_security}}
					</view>
				</view>
				<view class="tdistr_list">
					<view class="left">
						投标保证金
					</view>
					<view class="right">
						{{teamcontent.bid_security}}
					</view>
				</view>
				<view class="tdistr_list">
					<view class="left">
						保证金
					</view>
					<view class="right">
						{{teamcontent.security}}
					</view>
				</view>
			<!-- 	<view class="tdistr_list">
					<view class="left">
						建设单位企业性质
					</view>
					<view class="right">
						{{teamcontent.p_employer_unit}}
					</view>
				</view>
				<view class="tdistr_list">
					<view class="left">
						总包单位企业性质
					</view>
					<view class="right">
						{{teamcontent.p_total_employer_unit}}
					</view>
				</view> -->
				<view class="tdistr_list">
					<view class="left">
						项目资金到位情况
					</view>
					<view class="right">
						{{teamcontent.project_fund_availability}}
					</view>
				</view>
				<view class="tdistr_list">
					<view class="left">
						其他要求
					</view>
					<view class="right">
						{{teamcontent.other_requirement}}
					</view>
				</view>

			</view>
		</view>
		<view class="jianjie" v-if='user.group_id == 3'>
			<view class="title">
				联系方式
			</view>
			<view class="tdistr">
				<view class="tdistr_list">
					<view class="left">
						姓名
					</view>
					<view class="right">
						{{teamcontent.name}}
					</view>
				</view>
				<view class="tdistr_list">
					<view class="left">
						<text>联系电话</text>
					</view>
					<view class="right">
						{{teamcontent.phone}}
					</view>
				</view>
			</view>
		</view>
		<view class="jianjie" v-if='user.group_id == 2'>
			<view class="title">
				企业信息
			</view>
			<view class="tdistr">
				<view class="tdistr_list">
					<view class="left">
						企业类型
					</view>
					<view class="right">
						<text v-for="(e,eind) in teamcontent.troops_arr" :key="eind">{{e}}</text>
					</view>
				</view>
				<view class="tdistr_list">
					<view class="left">
						<text>涉及专业</text>
					</view>
					<view class="right">
						<text v-for="(e,eind) in teamcontent.work_arr" :key="eind">{{e}}
							<template v-if="eind != teamcontent.work_arr.length -1"> /
							</template>
						</text>
					</view>
				</view>
			</view>
		</view>
		<view class="jianjie" v-if='user.group_id == 2'>
			<view class="title">
				能力及业绩
			</view>
			<view class="tdistr">
				<view class="tdistr_list">
					<view class="left">
						服务能力
					</view>
					<view class="right">
						{{teamcontent.service}}
					</view>
				</view>
				<view class="tdistr_list">
					<view class="left">
						<text>垫资能力</text>
					</view>
					<view class="right">
						{{teamcontent.advance_money}}
					</view>
				</view>
				<view class="tdistr_list">
					<view class="left">
						<text>近2年内工程业绩</text>
					</view>
					<view class="right">
						{{teamcontent.achievement2}}
					</view>
				</view>
				<view class="tdistr_list">
					<view class="left">
						<text>获奖及受表彰情况</text>
					</view>
					<view class="right">
						{{teamcontent.prize}}
					</view>
				</view>
			</view>
		</view>
		<view class="jianjie" v-if='user.group_id == 2'>
			<view class="title">
				其他
			</view>
			<view class="tdistr">
				<view class="tdistr_list">
					<view class="left">
						可接受的工程区域
					</view>
					<view class="right">
						{{teamcontent.project_area}}
					</view>
				</view>
				<view class="tdistr_list">
					<view class="left">
						<text>是否接受业主或总包为民企</text>
					</view>
					<view class="right">
						{{teamcontent.material}}
					</view>
				</view>
				<view class="tdistr_list">
					<view class="left">
						<text>诉讼情况</text>
					</view>
					<view class="right">
						{{teamcontent.lawsuit}}
					</view>
				</view>
				<view class="tdistr_list">
					<view class="left">
						<text>其余诉求</text>
					</view>
					<view class="right">
						{{teamcontent.other_appeal}}
					</view>
				</view>
				<view class="tdistr_list">
					<view class="left">
						<text>总结性说明</text>
					</view>
					<view class="right">
						{{teamcontent.summary}}
					</view>
				</view>
			</view>
		</view>
		<view class="bottom">
			<view class="imgss">
				<view class="imgs" @tap="interest">
					<image v-if="!teamcontent.is_focus" src="@/static/icon/icon/home/guanzhu.png" mode="widthFix">
					</image>
					<image v-else src="@/static/icon/icon/home/guanzhu2.png" mode="widthFix"></image>
					<view class="">
						{{teamcontent.is_focus?'取消关注':'关注TA'}}
					</view>
				</view>
				<view class="imgs" @tap="toCollect">
					<image v-if="!teamcontent.is_collect" src="@/static/icon/icon/home/shoucang.png" mode="widthFix">
					</image>
					<image v-else src="@/static/icon/icon/home/shoucang2.png" mode="widthFix"></image>
					<view class="">
						{{teamcontent.is_collect?'取消收藏':'收藏'}}
					</view>
				</view>
				<button type="default" open-type="share">
					<view class="imgs">
						<image src="@/static/icon/icon/home/fenixang.png" mode="widthFix"></image>
						<view class="">
							分享
						</view>
					</view>
				</button>

			</view>
			<view class="queren" @tap="toCall()">
				联系咨询
			</view>
		</view>
	</view>
</template>

<script>
	const app = getApp()
	export default {
		data() {
			return {
				user: app.globalData.user,
				detailId: '',
				teamcontent: '',
				users: [],

			}
		},
		onLoad(options) {

			uni.getLocation({
				type: 'wgs84',
				success: function(res) {
					console.log('res-----', res)
				},
				fail: function(err) {
					console.log('err-----', err)
				}
			});
			if (options.id) {
				this.detailId = options.id
			}
			this.getDetail()
		},
		onShow() {
			if (app.globalData.user) {
				this.users = app.globalData.user
			} else {
				app.flagLogin().then(() => {
					console.log('回调2---------------', app.globalData.user)
					this.users = app.globalData.user

				})
			}
			if (this.user.group_id == 2) {

			} else {
				uni.setNavigationBarTitle({
					title: '企业详情'
				});
			}
		},
		methods: {
			// 获取详情
			getDetail() {
				let url
				if (this.user.group_id == 2) {
					url = 'addons/shopro/visiting_card/detail'

				} else {
					url = 'addons/shopro/project/detail'

				}
				uni.request({
					url: app.globalData.IP + url,
					data: {
						id: this.detailId
					},
					header: {
						token: app.globalData.token
					},
					method: 'GET',
					success: res => {
						console.log(res)
						if (res.data.code == 1) {
							this.teamcontent = res.data.data
						} else {
							uni.showToast({
								title: res.data.msg,
								icon: 'none'
							})
						}
					},
					fail: err => {
						uni.showToast({
							title: err.data.msg,
							icon: 'none'
						})
					}
				})
				// app.getData(url, {
				// 	id: this.detailId
				// }).then(res => {
				// 	this.teamcontent = res.data.data
				// 	console.log(this.teamcontent, '111111111111111111111111111')
				// })
			},
			// 关注
			interest() {
				
				uni.request({
					url: app.globalData.IP + 'addons/shopro/user_focus/focus',
					data: {
						user_id: this.teamcontent.user_id
					},
					header: {
						token: app.globalData.token
					},
					method: 'POST',
					success: res => {
						console.log(res)
						if (res.data.code == 1) {
							console.log('‘', res.data.data)
							if (res.data.data) {

								this.teamcontent.is_focus = 1
							} else {
								this.teamcontent.is_focus = 0
							}
							uni.showToast({
								title: res.data.msg,

							})
						} else {
							uni.showToast({
								title: '关注失败',
								icon: 'none'
							})
						}
					},
					fail: err => {
						console.log('发送数据失败')
					}
				})
			},
			// 收藏
			toCollect() {
				console.log(this.teamcontent.id)
				let _this = this
				let url = ''
				if(this.user.group_id == 2){
					url = 'addons/shopro/visiting_card/collect'
				}else{
					url = 'addons/shopro/project/collect'
				}
				uni.request({
					url: app.globalData.IP + url,
					data: {
						id: _this.teamcontent.id
					},
					header: {
						token: app.globalData.token
					},
					method: 'POST',
					success: res => {
						console.log(res)
						if (res.data.code == 1) {
							if (res.data.data) {
								this.teamcontent.is_collect = 1
							} else {
								this.teamcontent.is_collect = 0
							}
							uni.showToast({
								title: res.data.msg,

							})
						} else {
							uni.showToast({
								title: '收藏失败',
								icon: 'none'
							})
						}
					},
					fail: err => {
						reject(err)
						console.log('发送数据失败')
					}
				})
			},
			toCall() {
				uni.makePhoneCall({
					phoneNumber: this.teamcontent.phone //仅为示例
				});
			},
		},
		onShareAppMessage(options) {
			console.log(options)
			var that = this;
			let title = this.user.group_id == 3?'优质项目':'队伍名片'
			// 设置菜单中的转发按钮触发转发事件时的转发内容
			var shareObj = {
				title: "工头网给您分享了一个"+title, // 默认是小程序的名称(可以写slogan等)
				path: '/pages/home/home', // 默认是当前页面，必须是以‘/'开头的完整路径
				imageUrl: '', //自定义图片路径，可以是本地文件路径、代码包文件路径或者网络图片路径，支持PNG及JPG，不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
				success: function(res) {
					// 转发成功之后的回调
					if (res.errMsg == 'shareAppMessage:ok') {}
				},
				fail: function() {
					// 转发失败之后的回调
					if (res.errMsg == 'shareAppMessage:fail cancel') {
						// 用户取消转发
					} else if (res.errMsg == 'shareAppMessage:fail') {
						// 转发失败，其中 detail message 为详细失败信息
					}
				}
			}
			// 来自页面内的按钮的转发
			if (options.from == 'button') {
				var eData = options.target.dataset;
				console.log(eData); // shareBtn
				// 此处可以修改 shareObj 中的内容
				shareObj.path = '/pages/home/home'
			}
			// 返回shareObj
			return shareObj;
		}
	}
</script>

<style lang="scss">
	.list_top {
		display: flex;
		justify-content: flex-start;

		image {
			width: 100rpx;
			border-radius: 50%;
			margin-right: 20rpx;
		}

		.guanzhu {
			font-size: 20rpx;
			color: #fff;
			background-color: $uni-color-primary;
			margin-left: 90rpx;
			padding: 10rpx 20rpx;
			border-radius: 10rpx;
		}

		.list_title {
			.title_name {
				font-size: 28rpx;
				font-weight: bold;
				line-height: 52rpx;
			}

			.title_dizhi {
				font-size: 24rpx;
				color: #333;
				margin-top: 18rpx;
				margin-left: 20rpx;
			}
		}
	}

	.bottom {
		background-color: #fff;
	}

	.bottom_list {
		display: flex;
		justify-content: flex-start;
		margin: 20rpx 0;


		.bottom_lists,
		.bottom_lists2 {
			margin-right: 12rpx;
			font-size: 25rpx;
			text-align: center;
			padding: 4rpx 10rpx;
			background-color: #eee;
			margin-bottom: 12rpx;
		}

		.bottom_lists2 {
			width: 145rpx;
			color: var(--base);
			background: #E5F4FF;
			font-weight: 600;
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;
		}
	}

	.pingtai {
		padding-left: 270rpx;
		background-image: url('../../static/icon/renzheng.png');
		background-size: 100% 100%;
		background-repeat: no-repeat;
		height: 98rpx;
		display: flex;
		align-items: center;
		border-radius: 10rpx;

		.zheng {
			font-size: 24rpx;
			color: #888 !important;
			font-weight: 600;
			margin-right: 0;

			text {
				margin: 0 4rpx;
				font-weight: 400;
			}
		}

		image {
			width: 40rpx;
			height: 40rpx;
		}

		text {
			font-size: 28rpx;
			margin-right: 20rpx;
			font-weight: 700;
		}
	}

	.jianjie {
		margin-top: 40rpx;

		.title {
			font-size: 28rpx;
			font-weight: bold;
			margin-bottom: 20rpx;
		}

		.contents {
			font-size: 24rpx;
			font-size: 500;
		}
	}

	.tdistr {
		border: 1rpx solid #F7F7F7;
		border-radius: 20rpx;
		overflow: hidden;
	}

	.tdistr_list {
		display: flex;
		height: 100rpx;
		font-size: 22rpx;
		// line-height: 100rpx;
		font-weight: 700;
		border-bottom: 1rpx solid #F7F7F7;

		.left {
			width: 130rpx;
			text-align: center;
			background-color: #F7F7F7;
			display: flex;
			align-items: center;
			justify-content: center;
			padding: 0 12rpx;
		}

		.right {
			padding-left: 20rpx;
			display: flex;
			align-items: center;
			
			font-weight: 400;
			width: 80%;
			text-align: left;
		}
	}

	.tdistr_list:last-child {
		border-bottom: 0;
	}

	.bottom {
		display: flex;
		justify-content: space-between;
		align-items: center;
		width: 100vw;
		height: 100rpx;
		position: fixed;
		bottom: 0;
		border-top: 1px solid #dedede;

		.imgss {
			display: flex;
			justify-content: flex-start;

			button {
				padding: 0;
				margin: 0;
				line-height: normal;
				background: #fff;
				border: 0;
				border-radius: 0;
			}

			button::after {
				border: 0;
			}

			.imgs {
				width: 100rpx;
				text-align: center;

				image {
					width: 40rpx;
				}

				font-size: 16rpx;
			}
		}

		.queren {
			width: 50%;
			text-align: center;
			background: $uni-color-primary;
			height: 80%;
			border-radius: 30rpx;
			text-align: center;
			line-height: 80rpx;
			position: relative;
			left: -40rpx;
			color: #fff;
		}
	}
</style>
